#pragma once
#include "..\utils\GameMath.h"
//#include <vector>
#include "..\nodes\Node.h"
#include "..\renderer\IndexVertexBuffer.h"
#include "..\renderer\VertexDeclaration.h"
#include "..\content\ResManager.h"

namespace ds {

class ScreenQuad : public Node {

struct Quad {
	Vec3 position;
	//float uv[4];
	TexCoord tc;
	float dim[3];
};

typedef List<Quad> Quads;

public:
	ScreenQuad(const std::string& name,const std::string& materialName,int maxVertices,bool dynamic = false) 
		: Node(name,materialName,true) , m_MaxVertices(maxVertices) , m_Dynamic(dynamic) {}
	virtual ~ScreenQuad(void);	
	void init();
	void clear() {
		m_Quads.clear();
	}
	void add(const Vec3& pos,const Vec3& dimension,const Rect& rect);
	void add(float xp,float yp,float dimX,float dimY,const Rect& rect);
	virtual void loadContent(ResManager& resourceManager) {}
	void rebuild();
	void prepareRendering();
	void draw();
	void postRendering();
private:		
	TransformedTexturedBuffer* m_Buffer;
	Quads m_Quads;
	bool m_Dynamic;
	int m_MaxVertices;
};

class ColouredScreenQuad : public Node {

struct Quad {
	Vec3 position;
	float uv[4];
	float dim[3];
	Color color;
	float angle;
};

typedef List<Quad> Quads;

public:
	ColouredScreenQuad(const std::string& name,const std::string& materialName,int maxVertices,bool dynamic = false) 
		: Node(name,materialName,true) 
		, m_MaxVertices(maxVertices) 
		, m_Dynamic(dynamic) {}
	virtual ~ColouredScreenQuad(void);	
	void init();
	void clear() {
		m_Quads.clear();
	}
	void add(const Vec3& pos,const Vec3& dimension,const Rect& rect,const Color& color,float angle = 0.0f);
	void add(float xp,float yp,float dimX,float dimY,const Rect& rect,const Color& color,float angle = 0.0f);
	void rebuild();
	virtual void loadContent(ResManager& resourceManager) {}
	void prepareRendering();
	void draw();
	void postRendering();
private:		
	TransformedTextureColorBuffer* m_Buffer;
	Quads m_Quads;
	bool m_Dynamic;
	int m_MaxVertices;
};
}
